Inclusive Classification |
In SOME cases, it is possible to improve the performance of a classifier by adding an extra output to an artificial neural network to deal with those cases that do not belong to one of the others classes. The following problem illustrates how to add an additional output neuron to a classifier to improve its performance. En ALGUNOS casos, es posible mejorar el desempeño de una clasificador agregando una salida adicional a la salida de una red neuronal artificial para procesar aquellos casos que no pertenecen a algunas de las otras clases. El siguiente problema ilustra cómo agregar una neuronal de salida adicional a un clasificador para mejorar su desempeño. |
Problem 1 |
Create a New Project called Div57Inclusion (You must select: Multi-layer Network and Classification in the New Project Dialog) to classify the numbers that are divisible by 5 or by 7. However, the artificial neural network has an extra output that activates when the number is not divisible by 5 nor by 7. Cree un nuevo proyecto llamado Div57Inclusion (Usted debe seleccionar: Multi-layer Network and Classification en el diálogo de nuevo proyecto) para clasificar los números que son divisibles entre 5 o entre 8. Sin embargo, la red neuronal artificial tiene una salida adicional que se activa cuando el número no es divisible entre 5 ni entre 7. |
Div57Inclusion\BuildTrainSet.lab |
Matrix trainSetTarget; trainSetTarget.Create(32, 3); // Class1: divisible by 5, Class 2: divisible by 7, Class 3: the other numbers Matrix input; Matrix column; Matrix row; Vector number; int i = 0; for(i = 0; i<32; i++) { number.CreateBinary(5, i); // Convert to binary column = number; // Binary number in one column row = column.Transpose(); // Binary number in one row input.AppendDown(row); if (i%5 == 0 && i != 0) // Is divisible by 5 (class 1)? { trainSetTarget[i][0] = 1; } else if (i%7 == 0 && i != 0) // Is divisible by 7 (class 2)? { trainSetTarget[i][1] = 1; } else { trainSetTarget[i][2] = 1; } } input.AppendDown(input); input.AppendDown(input); input.AppendDown(input); input.AppendDown(input); input.Save(); // Save the input to create the validation set // Matrix noise; noise.CreateRandom(input.GetRowCount(), input.GetColCount(), 0.0, 1.0); Matrix trainSetInput = 0.9*input + 0.1*noise; trainSetInput.Save(); // trainSetTarget.AppendDown(trainSetTarget); trainSetTarget.AppendDown(trainSetTarget); trainSetTarget.AppendDown(trainSetTarget); trainSetTarget.AppendDown(trainSetTarget); trainSetTarget.Save(); |
Problem 2 |
Edit the BuilValidSet.lab file to build an appropriate validation set. Then, run the file. Edite el archivo BuilValidSet.lab para construir un conjunto de validación apropiado. Entonces, ejecute el archivo. |
Div57Inclusion\BuildValidSet.lab |
Matrix input; input.Load(); // Matrix noise; noise.CreateRandom(input.GetRowCount(), input.GetColCount(), 0.0, 1.0); Matrix validSetInput = 0.9*input + 0.1*noise; validSetInput.Save(); |
Problem 3 |
Edit the Train.lab file to design and train an ANN for the classification of numbers that are divisible by 5 or divisible by 7. Train the ANN using simulated annealing and the Conjugate Gradient method. Edite el archivo Train.lab para diseñar y entrenar una red neuronal artificial para la clasificación de los números que son divisibles entre 5 o entre 7. Entrene la RNA usando el templado simulado y el método del Gradiente Conjugado. |
Div57Inclusion\Train.lab |
//_________________________ Network Setup LayerNet net; net.Create(5, 3, 0, 3); // 3 Outputs means 3 Classes //____________________________ Input Scaling net.SetInScaler(0, 0.0, 1.0); net.SetInScaler(1, 0.0, 1.0); net.SetInScaler(2, 0.0, 1.0); net.SetInScaler(3, 0.0, 1.0); net.SetInScaler(4, 0.0, 1.0); //____________________________ Output Scaling net.SetOutScaler(0, 0.0, 1.0); net.SetOutScaler(1, 0.0, 1.0); net.SetOutScaler(2, 0.0, 1.0); //________________________ Load and set the training set Matrix trainSetInput; trainSetInput.Load(); Matrix trainSetTarget; trainSetTarget.Load(); net.SetTrainSet(trainSetInput, trainSetTarget, false); //________________________ Train net.TrainSimAnneal(20, 10, 15, 0.001, false, 4, 1.0e-12); net.TrainConjGrad(2000,1.0e-12); //_____________________________ Save the trained network net.Save(); |
Problem 4 |
Edit the CheckTraining.lab file to check the training: (a) Compute the confusion matrix using the training set. (b) Plot the error for each network output. (c) Save the confusion matrix as a vector image (checkTraining.emf). |
Problem 5 |
Edit the Validation.lab file to perform the validation of the ANN. (a) Compute the confusion matrix using the validation set. (b) Plot the error for each network output. (c) Save the confusion matrix as a vector image (Validation.emf). |